
---
- name: Backup ALL
  hosts: all
  connection: network_cli
  gather_facts: false

  tasks:

    - name: Accespt ansible net hostname
      ios_facts:
        gather_subset: all

    - name: Get current date
      local_action: command date +%Y-%b-%d
      register: date

    - name: Get current time
      local_action: command date +%H:%M
      register: time

    - name: Get running-config and save it
      ios_config:
       backup: yes
       backup_options:
         filename: "{{ ansible_net_hostname }}_{{ ansible_host }}.cfg"
         dir_path: /home/INFRASTRUCTURE/{{ date.stdout }}_at_{{ time.stdout }}

    - name: Tasks done
      debug: msg="All tasks has been done on {{ date.stdout }} at {{ time.stdout }}."
